#include "immediateupdatestrategy.h"
#include "statusbarmanager.h"
#include <QDebug>
void ImmediateUpdateStrategy::applyUpdate(const StatusBarState& newState,
                                        const StatusBarState& oldState,
                                        void* context)
{
    Q_UNUSED(context)
    if (!m_statusBarManager) {
        return;
    }
    // Martin Fowler重构：Extract Method - 细化更新逻辑
    // 只更新实际变化的部分以提高性能
    if (newState.fileInfoChanged(oldState)) {
        m_statusBarManager->updateStatus(newState.fileInfo());
    }
    if (newState.pageInfoChanged(oldState)) {
        // Martin Fowler重构：只更新总页数，不显示当前页
        m_statusBarManager->updateTotalPages(newState.totalPages());
    }
    if (newState.cacheInfoChanged(oldState)) {
        m_statusBarManager->updateCacheStatus(newState.cacheSize(), newState.cacheCount());
    }
    if (newState.systemStatusChanged(oldState)) {
        m_statusBarManager->updateSystemStatus(newState.systemStatus());
    }
    // 导出进度通过ExportStatusController管理，这里不直接处理
    if (newState.exportProgressChanged(oldState)) {
        // ExportStatusController已经在StatusBarManager中处理导出状态
    }
}